package com.fintech.third.constant;

import java.io.Serializable;
import java.util.HashMap;

import com.alibaba.fastjson.JSON;
import com.fintech.common.enums.RespStatus;

/**
 * 响应实体
 * @author 吴俊峰
 */
public class ResponseResult implements Serializable {
	
	private String errorCode;
	private String message;
	private Object data;
	
	public static ResponseResult getResult(String errorCode ,String message ,Object data){
		ResponseResult fintechResult = new ResponseResult();
		fintechResult.setData(data);
		fintechResult.setErrorCode(errorCode);
		fintechResult.setMessage(message);
		if(data == null) {
			data = new HashMap<String, Object>();
		}
		fintechResult.setData(data);
		return fintechResult;
	}
	public static ResponseResult getSuccessResult(String message, Object data){
		return getResult(RespStatus.SUCCESS.getCode()+"", message, data);
	}
	
	public static ResponseResult getFailResult(String message){
		return getResult(RespStatus.REQ_ERROR.getCode()+"", message, null);
	}
	
	public static ResponseResult getFailResult(String message, Object data){
		return getResult(RespStatus.REQ_ERROR.getCode()+"", message, data);
	}
	
	public static ResponseResult getExceptionResult(String message) {
		return getResult(RespStatus.ERROR.getCode()+"", message, null);
	}
	public String getErrorCode() {
		return errorCode;
	}

	public void setErrorCode(String errorCode) {
		this.errorCode = errorCode;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}
	
	@Override
	public String toString() {
		return JSON.toJSONString(this);
	}
}
